import axios from 'axios';

/**
 * 用户管理
 **/
// 用户管理-获取用户管理列表
export const userList = () => { return axios.get( 'http://localhost:9001/users/') };
export const userDetail = (userId) => { return axios.get(`http://localhost:9001/users/${userId}`) };
export const userDelete = (userId) => { return axios.delete(`http://localhost:9001/users/${userId}`).then(res => res.data) };

/*
评论管理
 */
export const commentList = () => { return axios.get( 'http://localhost:9001/comments/all') };
export const commentDetail = (commentId) => { return axios.get(`http://localhost:9001/users/${commentId}`) };
export const commentDelete = (commentId) => { return axios.delete(`http://localhost:9001/users/${commentId}`).then(res => res.data) };

/**
 * 新闻审核
 **/
// 获取所有新闻
export const getAllNews = () => { return axios.get('http://localhost:9001/news/') };

// 获取不同审核状态的新闻列表
export const getNewsByState = (state) => { return axios.get(`http://localhost:9001/news/state/${state}`) };

// 审核通过新闻
export const approveNews = (newsId) => { return axios.put(`http://localhost:9001/news/approve/${newsId}`) };

// 审核不通过新闻
export const rejectNews = (newsId) => { return axios.put(`http://localhost:9001/news/reject/${newsId}`) };

// 删除新闻
export const deleteNews = (newsId) => { return axios.delete(`http://localhost:9001/news/delete/${newsId}`).then(res => res.data) };
